package com.zuoye.Serviecs;

import com.zuoye.entity.Account;

import java.util.Scanner;

/**
 * @version v1.0
 * @Description
 * @Author admin
 * @date 2021/7/15  19:49
 * @Copyright
 */
public class SavingAcount extends Account  {
    //储蓄账户
    public Scanner scanner = new Scanner(System.in);


    public SavingAcount() {

    }

    public SavingAcount(String cardNo, String password, double balance) {
        super(cardNo, password, balance);
    }



    @Override
    public double deposit(double money , String number, String password) {
        do {

            for (int i = 0; i < Back.accounts.length; i++) {
                if (Back.accounts[i].cardNo.equals(number) && Back.accounts[i].password.equals(password)) {
                    System.out.println("请输入要取出的金额：");
                    money = scanner.nextDouble();
                    if (money > Back.accounts[i].balance) {
                        System.out.println("自己有多少钱心里没点数？ 重输：");

                    }else{
                    System.out.println("余额剩余："+ (Back.accounts[i].getBalance() - money));
                    Back.accounts[i].setBalance(Back.accounts[i].getBalance() - money);
                    }
                }
            }
            System.out.println("是否继续取：");
            String s1 = scanner.next();
            if (s1.equals("是")) {
                continue;
            } else {

            }
break;
        } while (true);

        return money;
    }


}
